/**
 * 模拟构建jquery库
 * */
var $ = jquery = function (selector, context) {
    return new jquery.fn.init(selector, context);
};
jquery.fn = jquery.prototype = {
    init: function (selector, context) {
        // debugger;
        selector = selector || document;
        context = context || document;
        if (selector.nodeType) {
            this[0] = selector;
            this.length = 1;
            this.context = selector;
            return this;
        }
        if (typeof selector == "string") { //选择符为字符串
            var e = document.getElementsByTagName(selector);
            for (var i = 0; i < e.length; i++) {
                this[i] = e[i];
            }
            this.length = e.length;
            this.context = context; //设置实例的属性，返回选择范围；
            return this;
        } else {
            this.length = 0;
            this.context = context;
            return this;
        }
    },
    version: "1.0.1",
    size: function () {
        return this.length;
    },
    html: function (val) {
        return val === undefined ? (this[0] ? this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") :
            null) :
            this.empty().append(val);
    },
    setOptions: function (options) {
        this.options = {
            start: '#000',
            end: '#ddc',
            Background: false,
            step: 20,
            speed: 10
        };
        jQuery.extend(this.options, options || {});
    }
}
jquery.fn.init.prototype = jquery.fn;
jquery.extend = jquery.fn.extend = function (destination, source) {
    for (var name in source) {
        destination[name] = source[name];
        return destination;
    }
}
jquery.fn.extend({
    test: function () {
        alert('tuozhan');
    }
})

function l(o) {
    console.log(o);
}
